home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / DEV / I-Z / Xlisp_Source.cpt / xlisp.c < prev    next >
C/C++ Source or Header  |  1980-01-01  |  2KB  |  90 lines

  1. /* xlisp - an experimental version of lisp that supports object-oriented
  2.            programming */
  3.  
  4. #include "xlisp.h"
  5.  
  6. /* define the banner line string */
  7. #define BANNER    "XLISP version 1.4a, Copyright (c) 1985, by David Betz"
  8.  
  9. /* external variables */
  10. extern NODE *s_stdin,*s_stdout;
  11. extern NODE *s_evalhook,*s_applyhook;
  12. extern NODE *true;
  13.  
  14. /* main - the main routine */
  15. main(argc,argv)
  16.   int argc; char *argv[];
  17. {
  18.     char fname[20];
  19.     CONTEXT cntxt;
  20.     NODE expr;
  21.     int i;
  22.  
  23.     /* print the banner line */
  24. #ifdef MEGAMAX
  25.     macinit(BANNER);
  26. #else
  27.     printf("%s\n",BANNER);
  28. #endif
  29.  
  30.     /* setup initialization error handler */
  31.     xlbegin(&cntxt,CF_ERROR,(NODE *) 1);
  32.     if (setjmp(cntxt.c_jmpbuf)) {
  33.     printf("fatal initialization error\n");
  34.     exit();
  35.     }
  36.  
  37.     /* initialize xlisp */
  38.     xlinit();
  39.     xlend(&cntxt);
  40.  
  41.     /* reset the error handler */
  42.     xlbegin(&cntxt,CF_ERROR,true);
  43.  
  44.     /* load "init.lsp" */
  45.     if (setjmp(cntxt.c_jmpbuf) == 0)
  46.     xlload("init",FALSE,FALSE);
  47.  
  48.     /* load any files mentioned on the command line */
  49. #ifndef MEGAMAX
  50.     if (setjmp(cntxt.c_jmpbuf) == 0)
  51.     for (i = 1; i < argc; i++) {
  52.         strcpy(fname,argv[i]); strcat(fname,".lsp");
  53.         if (!xlload(fname,TRUE,FALSE))
  54.         xlfail("can't load file");
  55.     }
  56. #endif
  57.  
  58.     /* create a new stack frame */
  59.     xlsave(&expr,NULL);
  60.  
  61.     /* main command processing loop */
  62.     while (TRUE) {
  63.  
  64.     /* setup the error return */
  65.     if (setjmp(cntxt.c_jmpbuf)) {
  66.         s_evalhook->n_symvalue = NIL;
  67.         s_applyhook->n_symvalue = NIL;
  68.     }
  69.  
  70.     /* read an expression */
  71.     if (!xlread(s_stdin->n_symvalue,&expr.n_ptr))
  72.         break;
  73.  
  74.     /* evaluate the expression */
  75.     expr.n_ptr = xleval(expr.n_ptr);
  76.  
  77.     /* print it */
  78.     stdprint(expr.n_ptr);
  79.     }
  80.     xlend(&cntxt);
  81. }
  82.  
  83. /* stdprint - print to standard output */
  84. stdprint(expr)
  85.   NODE *expr;
  86. {
  87.     xlprint(s_stdout->n_symvalue,expr,TRUE);
  88.     xlterpri(s_stdout->n_symvalue);
  89. }
  90.